//
//  KFDMarketFinancialEventTableViewCell.m
//  
//
//  Created by JIRENTIANXIANG on 6/18/15.
//
//

#import "KFDMarketFinancialEventTableViewCell.h"
#import "JRTXLinearLayout.h"
#import "ui_config.h"
#import "KFDFinancialEventCellBottomBar.h"

@interface KFDMarketFinancialEventTableViewCell ()

@property (assign,nonatomic) CGFloat height;
@property (strong,nonatomic) JRTXLinearLayout* verticalLayout;

@end

@implementation KFDMarketFinancialEventTableViewCell

-(instancetype)init
{
    if (self=[super init]) {
        self.backgroundColor=KFD_BG_COLOR;
//        self.contentView.backgroundColor=KFD_BG_COLOR;
        self.separatorInset=UIEdgeInsetsMake(0, 0, 0, SCREEN_WIDTH);
    }
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)attach
{
    [self.contentView addSubview:self.verticalLayout.view];
}

-(void)layout
{
    self.verticalLayout=[[JRTXLinearLayout alloc] initWithFrame:CGRectMake(18, 0, SCREEN_WIDTH-2*18, 0)];
    [self.verticalLayout appendBlankLineWithHeight:12];
    UILabel* contentLabel=[[UILabel alloc] init];
    contentLabel.font=[UIFont systemFontOfSize:13];
    contentLabel.text=self.financialEvent.content;
    [self.verticalLayout appendLabel:contentLabel widthLimit:SCREEN_WIDTH-2*18 alignment:JRTXLinearLayoutAlignmentLeft];
    [self.verticalLayout appendBlankLineWithHeight:3];
    UILabel* timeLabel=[[UILabel alloc] init];
    timeLabel.text=self.financialEvent.time;
    timeLabel.font=[UIFont systemFontOfSize:11];
    timeLabel.textColor=KFDColorRGB(0x99, 0x99, 0x99);
    [self.verticalLayout appendLabel:timeLabel withoutStartingNewLineWithwidthLimit:100 alignment:JRTXLinearLayoutAlignmentLeft];
    KFDFinancialEventCellBottomBar* bottomBar=[[NSBundle mainBundle] loadNibNamed:@"KFDFinancialEventCellBottomBar" owner:nil options:nil].firstObject;
    bottomBar.frame=CGRectMake(0, 0, SCREEN_WIDTH-2*18, 12);
    bottomBar.event=self.financialEvent;
    [self.verticalLayout appendView:bottomBar alignment:JRTXLinearLayoutAlignmentLeft];
//    UIImageView* clockIcon=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 12, 12)];
//    clockIcon.contentMode=UIViewContentModeScaleAspectFit;
//    clockIcon.image=[UIImage imageNamed:@"time-gray-ico"];
//    [self.verticalLayout appendView:clockIcon alignment:JRTXLinearLayoutAlignmentLeft];
    self.height=self.verticalLayout.view.bounds.size.height;
}

@end
